package ink.lovejinhu.leetcodeMatch;

/**
 * @author jinhu
 * created 2021-07-04 11:11
 */
public class Solution_5801 {
    public int eliminateMaximum(int[] dist, int[] speed) {
        for (int j = 0; j < dist.length; j++) {   //表示第几轮
            if (dist[j] <= 0) {
                return j + 1 - 1;
            }

            for (int i = j + 1; i < dist.length; i++) {   //每一轮必须要消灭这一轮的怪物
                dist[i] = dist[i] - speed[i];
                if (dist[i] == 0) {

                    return j + 1;
                }
                if (dist[i] < 0) {
                    return j + 1 - 1;

                }
            }
            if (j < dist.length - 1) {
                if (dist[j + 1] <= 0) {
                    return j;
                }
            }

        }

        return dist.length;
    }

    public static void main(String[] args) {
        Solution_5801 solution_5801 = new Solution_5801();
        int[] dist = {1, 3, 4};
        int[] speed = {1, 1, 1};
        int i = solution_5801.eliminateMaximum(dist, speed);
        System.out.println(i);

    }
}
